package com.book.system.service.impl;

import com.book.system.dao.BookDao;
import com.book.system.entity.BookInfo;
import com.book.system.entity.LendList;
import com.book.system.service.BookService;

import java.time.LocalDate;
import java.time.temporal.ChronoUnit;
import java.util.List;
import java.util.Map;

public class BookServiceImpl implements BookService {

    /**
     * 图书管理持久层对象
     */
    private final BookDao bookDao = new BookDao();
    public List<Map<String, Object>> getList(String name, Integer classId) {
        List<Map<String, Object>> list = bookDao.getList(name, classId);
        return list;
    }
    /**
     * 添加图书
     * @param book 图书实体类
     * @return int
     */
    @Override
    public int add(BookInfo book) {
        //设置上架时间
        book.setPubDate(LocalDate.now());
        //设置ISBN 默认值
        book.setIsbn("9787550252585");
        return bookDao.add(book);
    }
    /**
     * 修改图书
     * @param book 图书实体类
     * @return int
     */
    @Override
    public int updateById(BookInfo book) {
        return bookDao.updateById(book);
    }

    /**
     * 删除图书
     *
     * @param id 图书编号
     * @return int
     */
    @Override
    public int delete(Integer id) {
        return bookDao.delete(id);
    }
}
